package com.kun.comic.fragment;

import java.util.Calendar;

import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.method.LinkMovementMethod;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.kun.comic.R;

public class HomeFragment extends Fragment {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		getActivity().setTitle(getString(R.string.app_name));
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_home, container,
				false);
		TextView tvContent = (TextView) rootView.findViewById(R.id.txt);
		tvContent.setGravity(Gravity.CENTER_HORIZONTAL);
		tvContent.setMovementMethod(LinkMovementMethod.getInstance());
		String ab = "Comic reader is FREE app.\n Every comic in app use of VECHAI.INFO";
		String support = "Onepiece \n Hiệp khách giang hồ \n Long phi bất bại P2 \n Naruto \n Onepunch-Man \n Conan \n Fairy tail \n Doremon \n Ô long viện 2";
		tvContent.setText(ab + "\n \n \n \n " + support);
		TextView tvDev = (TextView) rootView.findViewById(R.id.dev);
		String x;
		try {
			x = getString(R.string.copyright,
					Calendar.getInstance().get(Calendar.YEAR))
					+ " ver "
					+ getActivity().getPackageManager().getPackageInfo(
							getActivity().getPackageName(), 0).versionName;
			tvDev.setText(x);
		} catch (NameNotFoundException e) {
			e.printStackTrace();
		}

		// Ads google
		AdView mAdView = (AdView) rootView.findViewById(R.id.adView);
		AdRequest adRequest = new AdRequest.Builder().build();
		mAdView.loadAd(adRequest);
		return rootView;
	}
}
